<?php
//----------------------------------------------------------------------------//
// File              : V_QuyHoachAdd										  //
// Modification       :														  //
//----------------------------------------------------------------------------//
// Date(yyyy.mm.dd)   Developer                       Action				  //
//----------------------------------------------------------------------------//
// 2007.03.05         Tran Thanh                     Created				  //
//----------------------------------------------------------------------------//
?>
<script language=javascript>
function doUpload() 
{
	if (document.frm.tieu_de.value=="") {
		alert("Tiêu đề file không được rỗng");
		document.frm.tieu_de.focus();
		return false;
	}
	
	var filename = document.frm.userfile.value;
	var dotpos;
	filename = filename.substring(filename.lastIndexOf("\\")+1,filename.length);
	dotpos=filename.lastIndexOf('.');
	ext=filename.substr(dotpos+1,3);
	ext=ext.toLowerCase();
	fname=filename.substr(0,dotpos);
	if (document.frm.userfile.value!="") {
		if(dotpos==-1||dotpos==0){
			alert("Xin lỗi bạn click vào browser để chọn đúng đường dẫn.");
			return false;
		}
	}

	/*if (ext!="")
		if ((ext!="gif") && (ext!="jpg") && (ext!="png")  && (ext!="bmp")){
			alert("We only accept file format of GIF, JPG, PNG. Please try again.");
			return false;
		}*/

	return true;
}
function Focus(){
	document.frm.tieu_de.focus();
}
function showImage(urlimage)
{
	
	if(document.frm.userfile.value!=""){
		choseImage(document.frm.userfile.value);
		
	}else{
		choseImage(urlimage);
	}
}


function btnClearImgOnclick(){
	if (document.frm.userfile.value != ""){
		if (confirm("Bạn có muốn xóa ảnh không?")){
			document.frm.previewField.src = "";
			//document.f.chu_thich_anh.value = "";
			document.getElementById("fn").value='';
			document.getElementById("fileIDSpan").innerHTML=
					"<input name=\"userfile\" type=\"file\" id=\"fn\"  size=\"100\" value=\"\" onChange=\" showImage();\"/>";
		}
	}
}

</script>

<?php
include("../fckeditor/fckeditor.php") ;
function V_DownloadBaogiaAdd(&$arrayData,$mode)
{
	global $arrayError;
	$ulr = "?".MODUL."=downloadbaogia&".ACTION."=".$mode;

	$strButtonLabel ="Ghi lại";
	$strLabel ="Sửa file download báo giá";
	if ($mode == "Add"){
		$strButtonLabel ="Thêm mới";	
		$strLabel ="Thêm mới file download báo giá";
	}	
	
//	htmlentities(
?>
<?= CM_showError() ?>
<?php
	
	$ten_file=$arrayData['ten_file'];
	$url_file=DIR_UPLOADFILE_DOWNLOAD_BAO_GIA.$ten_file;
?>
<style type="text/css">
<!--
.style1 {color: #000099}
.style2 {
	color: #000000;
	font-weight: bold;
}
-->
</style>
<body>
<table width="100%" border="1" cellpadding="3" cellspacing="0" bordercolor="#FF9900" bordercolordark="white">
<form enctype="multipart/form-data" action="<?=$ulr?>" method="post" name="frm" id="frm" onSubmit="return doUpload();">
	<input type="hidden" name="id" value="<?=htmlspecialchars($arrayData["id"])?>" />
	<input type="hidden" name="curPg" value="<?=CM_getParameter("curPg");?>" />
	
	
        <tr>
          <td colspan="2" bgcolor="#FFE59F"  class=bk12-140><div align="center"><font size="3"><b><?=$strLabel?></b></font></div></td>
        </tr>
        
		 <tr>
          <td  bgcolor="#FFE59F"><span class="style1"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Tiêu đề:</font></span><span style="color:#FF0000;">*</span></td>
          <td >
          <input name="tieu_de" type="text" id="tieu_de" value="<?=htmlspecialchars($arrayData["tieu_de"])?>" size="100" maxlength="255" />
         </td>
		  
        </tr>
		
		<tr>
          <td  bgcolor="#FFE59F" >
		  	  <font size="2" face="Verdana, Arial, Helvetica, sans-serif">
			  		<span class="style1">File Upload:</span>
              </font>
		 </td>
		 <td ><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
		  <?
		  	if($mode=="Edit"){
		  ?>
		  		<font size="2" face="Verdana, Arial, Helvetica, sans-serif"> <?=htmlspecialchars($arrayData["ten_file"])?></font><br>
		 <?
		 	}else{}
		 ?>
		 	<span id="fileIDSpan">
            <input name="userfile" type="file" id="fn"  size="80" value="<?=htmlspecialchars($arrayData["ten_file"])?>"/>
          </span></font>
		  </td>
     
    </tr>
	
	
				<script language = 'JavaScript' >
				function backToList(){
					location = '<? echo "?".MODUL."=downloadbaogia&".ACTION."=List&curPg=".CM_getParameter("curPg")."";?>';
					return;
				}
				</script>
				<tr>
					<td colspan="2" align="center">
						<input name="Reset" type="reset" value="Nhập lại" />
						<input name="Submit" type="submit" value="<?=$strButtonLabel?>" />
						<input type="button" name="back" value="Trở lại " onClick="javascript: return backToList();">
						<!-- <input type="button" name="back" value=" Trở lại " onClick="history.go(-1)"> -->
					</td>
				</tr>
			</tbody>
<input type=hidden name="modul" value="<?=CM_getParameter("modul")?>"> 
<input type=hidden name="<?=ACTION2?>" value="<?=CM_getParameter(ACTION2)?>"> 
<input type=hidden name="textfield" value="<?=CM_getParameter("textfield")?>"> 
</form>
</table>
</body>
<?php
}
?>
